package com.applancer.parser;

import java.net.URLDecoder;

import org.json.JSONObject;

import android.text.Html;

import com.applancer.model.FeedModel;
import com.applancer.model.GeneralModel;

public class FeedParser extends GeneralParser {

	@Override
	public GeneralModel parseModel(JSONObject obj) {
		FeedModel model = new FeedModel();

		try {
			model.setId(obj.getString("Id"));
		} catch (Exception e) {
		}

		try {
			String temp = obj.getString("Title");

			String htmlencode = Html.fromHtml(temp).toString();
			String xmlencode = htmlencode.replace("&#8217;", "'");
			String finalStr = URLDecoder.decode(xmlencode, "UTF-8");
			model.setTitle(finalStr);

		} catch (Exception e) {
		}

		try {
			model.setContent(obj.getString("Content"));
		} catch (Exception e) {
			model.setContent("");
		}

		try {
			model.setDate(obj.getString("Date"));
		} catch (Exception e) {
		}

		try {
			model.setAuthor(obj.getString("Author"));
		} catch (Exception e) {
			model.setAuthor("");
		}

		try {
			model.setUrl(obj.getString("Url"));
		} catch (Exception e) {
			model.setUrl("");
		}

		try {
			model.setCountCommentFB(obj.getString("CountCommentFB"));
		} catch (Exception e) {
			model.setCountCommentFB("");
		}

		try {
			model.setCountLikeFB(obj.getString("CountLikeFB"));
		} catch (Exception e) {
			model.setCountLikeFB("");
		}

		try {
			model.setCountShareFB(obj.getString("CountShareFB"));
		} catch (Exception e) {
			model.setCountShareFB("");
		}

		try {

			model.setUrlImageThumb(obj.getString("UrlImageThumb"));
		} catch (Exception e) {
			model.setUrlImageThumb("");
		}
		return model;
	}
}
